/**
 * 
 */
package com.collabscm.md.base.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.collabscm.md.base.dao.OrganDao;
import com.collabscm.md.base.model.Organ;
import com.collabscm.md.base.service.OrganService;
import com.collabscm.pf.dao.DatabaseDao;
import com.collabscm.pf.service.support.DomainServiceSupport;
import com.collabscm.pf.vo.PageObject;

/**
 * @author tony
 * 组织service的实现类
 */
@Service("organService")
public class OrganServiceImpl extends DomainServiceSupport<Organ, Long> implements OrganService {
	private static final long serialVersionUID = 1L;
	
	@Autowired
	private OrganDao<Organ, Long> organDao;
	
	@Override
	protected DatabaseDao<Organ, Long> getDatabaseDao() {
		return organDao;
	}

	/**
	 * 得到所有的组织
	 * @return PageObject对象
	 */
	@Override
	public PageObject<Organ> getAllOrgan(Organ organ, PageObject<Organ> page) {
		List<Organ> organList = organDao.getAllOrgan(page.getStartIndex(), page.getPageSize());
		logger.debug("组织列表大小为 {}" + organList.size());
		page.setItems(organList);
		Integer totalSize = organDao.getCountOrgan();
		page.setTotalSize(totalSize);
		return page;
	}

	/**
	 * 创建组织
	 * @param organ
	 */
	@Override
	public void addOrgan(Organ organ) {
		//organ.setOrganId(organDao.getOrganId());
		//organ.setOrganId(new Long(3));
		organDao.createOrgan(organ);
		logger.debug("创建组织成功");
	}
	
	/**
	 * 得到organId
	 * @return 
	 */
	@Override
	public Long getOrganId() {
		return organDao.getOrganId();
	}

}
